package cn.edu.zafu.bigdata.lyq.work5;
import java.util.*;
import java.util.List;

public class findMax{

    // 泛型方法，返回列表中的最大元素
    public static <T extends Comparable<T>> T findMax(List<T> list) {
        if (list == null || list.isEmpty()) {
            throw new IllegalArgumentException("List must not be null or empty");
        }

        T max = list.get(0);
        for (T element : list) {
            if (element.compareTo(max) > 0) {
                max = element;
            }
        }
        return max;
    }
}
